//导航栏标题
export interface Data{
	title:string
}
interface RootObject {
  _type: string;
  instrumentation: Instrumentation;
  readLink: string;
  webSearchUrl: string;
  queryContext: QueryContext;
  totalEstimatedMatches: number;
  nextOffset: number;
  currentOffset: number;
  value: Value[];
}

export interface Value {
  webSearchUrl: string;
  webSearchUrlPingSuffix: string;
  name: string;
  thumbnailUrl: string;
  datePublished: string;
  isFamilyFriendly: boolean;
  contentUrl: string;
  contentUrlPingSuffix: string;
  hostPageUrl: string;
  hostPageUrlPingSuffix: string;
  contentSize: string;
  encodingFormat: string;
  hostPageDisplayUrl: string;
  width: number;
  height: number;
  hostPageFavIconUrl?: string;
  hostPageDomainFriendlyName?: string;
  cDNContentUrl?: string;
  hostPageDiscoveredDate: string;
  thumbnail: Thumbnail;
  imageInsightsToken: string;
  insightsMetadata: InsightsMetadata;
  imageId: string;
  accentColor: string;
}

interface InsightsMetadata {
  pagesIncludingCount: number;
  availableSizesCount: number;
}

interface Thumbnail {
  width: number;
  height: number;
}

interface QueryContext {
  originalQuery: string;
  alterationDisplayQuery: string;
  alterationOverrideQuery: string;
  alterationMethod: string;
  alterationType: string;
}

interface Instrumentation {
  _type: string;
  pingUrlBase: string;
  pageLoadPingUrl: string;
}
//img请求返回数据
interface ajax{
	url:string,
	data?:object,
	header?:object,
	method?:'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT',
	dataType?:string
}
export function Ajax(option:ajax):Promise<RootObject>{
	return new Promise((resolve,reject)=>{
		uni.request({
			url:option['url'],
			method:option['method'],
			header:option['header'],
			data:option['data'],
			success: (res:any) => resolve(res.data),
			fail: (rej) => reject(rej)
		})
	})
}